<template>
	<view class="page">
		<pageTxt>
			<!--  v-model="dataList" @query="queryList" -->
			<z-paging ref="paging" refresher-only @onRefresh="onRefresh" :paging-style="{ 'background-color': '#f7f7f7', height: '100%', width: '100%' }">
				<!-- 头部 -->
				<template slot="top">
					<u-navbar title="对客日志详情" :autoBack="true" :fixed="false"></u-navbar>
					<!-- <view class="tab-box">
						<u-tabs :current="tabIndex" @click="tabClickFunc" :list="tablist"
							inactiveStyle="color: #919092;" activeStyle="color: #3B75FF;" lineColor="#3B75FF"></u-tabs>
					</view> -->
				</template>
				<!-- 内容 -->
				<view class="detail-content-box" v-if="dataObj">
					<u-empty
						v-if="!$fieldShowFunc('15-dkrz') && !$fieldShowFunc('15-xmxx')"
						marginTop="300rpx"
						icon="https://hzybucket.obs.cn-south-1.myhuaweicloud.com/we_chat/no-msg2.png"
						text=" "
					></u-empty>
					<view class="item-box" v-if="$fieldShowFunc('15-xmxx')">
						<view class="title">项目信息</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('dk_xmmc')">
							<text class="txt">项目名称</text>
							<view class="content">
								{{ dataObj.project_name }}
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('dk_xmbh')">
							<text class="txt">项目编号</text>
							<view class="content">
								<text class="txt-btn" @click="navToProjectFunc">{{ dataObj.project_number }}</text>
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('dk_xmpp')">
							<text class="txt">项目品牌</text>
							<view class="content">
								{{ dataObj.brand_name }}
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('dk_xmlx')">
							<text class="txt">项目类型</text>
							<view class="content">
								{{ dataObj.store_type_name }}
							</view>
						</view>
					</view>
					<view class="item-box" v-if="$fieldShowFunc('15-dkrz')">
						<view class="title">对客日志</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('dk_bcgtnr')">
							<text class="txt">本次沟通内容</text>
							<view class="content">
								{{ dataObj.content || '--' }}
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('dk_gjfs')">
							<text class="txt">跟进方式</text>
							<view class="content">
								<template v-if="dataObj.follow_up_method == 1">电话</template>
								<template v-if="dataObj.follow_up_method == 2">微信</template>
								<template v-if="dataObj.follow_up_method == 3">企微</template>
								<template v-if="dataObj.follow_up_method == 4">邮件</template>
								<template v-if="dataObj.follow_up_method == 5">上门拜访</template>
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('dk_bcgtjd')">
							<text class="txt">沟通阶段</text>
							<view class="content">
								<template v-if="dataObj.communication_stage == 1">勘场</template>
								<template v-if="dataObj.communication_stage == 2">报价</template>
								<template v-if="dataObj.communication_stage == 3">洽谈</template>
								<template v-if="dataObj.communication_stage == 4">签约</template>
								<template v-if="dataObj.communication_stage == 5">结算</template>
								<template v-if="dataObj.communication_stage == 6">售后</template>
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('dk_yxqyje')">
							<text class="txt">意向签约金额</text>
							<view class="content">
								{{ dataObj.intended_signing_amount ? dataObj.intended_signing_amount + '元' : '--' }}
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('dk_xcgtsj')">
							<text class="txt">下次沟通时间</text>
							<view class="content">
								{{ dataObj.next_communication_time || '--' }}
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('dk_sfxyzcgt')">
							<text class="txt">是否需要再次沟通</text>
							<view class="content">
								{{ dataObj.is_communicate_again == 1 ? '是' : '否' }}
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('dk_rzwj')">
							<text class="txt">日志附件</text>
							<view class="content flex ac flex">
								<view v-if="!dataObj.customer_log_files.length">--</view>
								<image
									v-for="(item, index) in dataObj.customer_log_files"
									:key="index"
									:src="$fileImgFunc(item)"
									@click="previewFunc(item)"
									mode="aspectFill"
									class="img-box"
								></image>
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('dk_cjr')">
							<text class="txt">创建人</text>
							<view class="content">
								{{ dataObj.handlers_name || '--' }}
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('dk_cjsj')">
							<text class="txt">创建时间</text>
							<view class="content">
								{{ dataObj.created_at || '--' }}
							</view>
						</view>
					</view>
				</view>
			</z-paging>
		</pageTxt>
		<!-- 文件预览 -->
		<preFileCom :fileObj="fileObj" @onFileSuccess="fileObj = ''"></preFileCom>
	</view>
</template>

<script>
export default {
	data() {
		return {
			fileObj: '',
			loading: true,
			dataObj: '',
			tabIndex: 0,
			tablist: [
				{
					name: '项目信息'
				},
				{
					name: '对客日志'
				}
			]
		};
	},
	onLoad(option) {
		this.saleCustomerLogDetails(option.id);
	},
	methods: {
		onRefresh() {
			this.saleCustomerLogDetails(this.dataObj.id);
			this.$refs.paging.complete();
		},
		tabClickFunc(e) {
			this.tabIndex = e.index;
		},
		// 对客日志详情
		saleCustomerLogDetails(id) {
			this.$Apipc
				.saleCustomerLogDetails({
					id
				})
				.then((res) => {
					console.log(res, '对客日志详情');
					if (res.code == 200) {
						this.dataObj = res.data;
					}
				});
		},
		// 预览
		previewFunc(item) {
			this.fileObj = item;
		},
		// 去项目详情
		navToProjectFunc() {
			uni.navigateTo({
				url: '/pagesB/projectDetail/projectDetail?id=' + this.dataObj.project_id
			});
		}
	}
};
</script>

<style lang="scss" scoped>
@import 'customerLogDetail.scss';
</style>
